<script>
    var query_datas;  //记录所有数据
    $.post('{{ urlfor "InputDiagnosisController.Index" }}',{'kwd':getQueryVariable('kwd'), 'query_type':getQueryVariable('query_type')}, function(res){
       if(res.code == 0) {
           var result = [];
           if(res.data.inspects.length > 0) {  //检查
               result.push('<tr><td colspan="9" style="text-align: left; background-color:#ffd;">+ 检查</td></tr>');
               $.each(res.data.inspects, function(key, val) {
                   result.push('<tr data-type="inspects" data-index="'+ key +'"><td>'+ val.Number +'</td><td>'+ val.ProductName +'</td><td>'+ val.Unit +'</td><td></td><td>'+ val.UnitPrice +'</td><td></td><td></td><td></td><td></td></tr>');
               });
           }
           if(res.data.drug.length > 0) {  //药品
               result.push('<tr><td colspan="9" style="text-align: left; background-color: #ffd;">+ 药品</td></tr>');
               $.each(res.data.drug, function(key, val) {
                   var pro = val.Products;
                   result.push('<tr data-type="drug" data-index="'+ key +'"><td>'+ pro.BarCode +'</td><td>'+ pro.FullName +' </td><td>'+ pro.Unit +'</td><td>'+ pro.Spec +'</td><td>'+ val.suggested_price +'</td><td>'+ val.purchase_num +'</td><td>'+ pro.Manufacturer +'</td><td>'+ val.Acceptance.lot_number +'</td><td>'+ timetransDate(val.Acceptance.expiry_date) +'</td></tr>');
               });
           }
           if(result.length > 0) {
               $('#show_tr').html(result.join(''));
           }
           query_datas = res.data;
       }
    });
    $('.am-table').on('dblclick', 'tbody > tr', function(){
        if(typeof parent.presc_content_callback == 'function') {
            var type = $(this).data('type');
            var index = $(this).data('index');
            parent.presc_content_callback(type,query_datas[type][index]);
            closeInputQueryList();
        }
    })
</script>